package edu.towson.cosc603.coffeemaker;

import junit.framework.TestCase;

import org.junit.Before;
import org.junit.Test;

/**
 *
 */
public class CoffeeMakerTest extends TestCase {
	private CoffeeMaker cm;
	private Inventory i;
	private Recipe r1;
	private Recipe r2;

	@Before
	public void setUp() {
		cm = new CoffeeMaker();
		i = cm.checkInventory();

		r1 = new Recipe();
		r1.setName("Coffee");
		r1.setPrice(50);
		r1.setAmtCoffee(6);
		r1.setAmtMilk(1);
		r1.setAmtSugar(1);
		r1.setAmtChocolate(0);
		
		r2= new Recipe();
		r2.setName("CoffeeTea");
		r2.setPrice(20);
		r2.setAmtCoffee(4);
		r2.setAmtMilk(2);
		r2.setAmtSugar(4);
		r2.setAmtChocolate(5);
	}
	@Test
	public void testAddRecipe1() {
		assertTrue(cm.addRecipe(r1));
	}
	@Test
	public void testDeleteRecipe1() {
		cm.addRecipe(r1);
		assertTrue(cm.deleteRecipe(r1));
	}
	@Test
	public void testEditRecipe1() {
		cm.addRecipe(r1);
		Recipe newRecipe = new Recipe();
		newRecipe = r1;
		newRecipe.setAmtSugar(2);
		assertTrue(cm.editRecipe(r1, newRecipe));
	}
	
	
	@Test 
	public void testAddInventory()
	{
		int amtChocolate=1;
		int amtCoffee=1;
		int amtMilk=1;
		int amtSugar=0;
		
		boolean aaddInventory = cm.addInventory(amtCoffee, amtMilk, amtSugar, amtChocolate);
		assertTrue(aaddInventory);
	}
	@Test
	public void testNegativeAddInventory()
	{
		int amtChocolate=-1;
		int amtCoffee=-1;
		int amtMilk=-1;
		int amtSugar=0;
		
		boolean aaddInventory = cm.addInventory(amtCoffee, amtMilk, amtSugar, amtChocolate);
		assertFalse(aaddInventory);
	}
	
	public void testAddInventory1(){
		int amtChocolate1=1;
		int amtCoffee1=1;
		int amtMilk1=1;
		int amtSugar1=-2;
		
		boolean addInventoryTrue = cm.addInventory(amtCoffee1, amtMilk1, amtSugar1, amtChocolate1);
		assertFalse(addInventoryTrue);
	}
	
	public void testMakeCoffee(){
		Inventory testInventory = new Inventory();
		
		int amtPaid=50;
		Recipe testRecipe = new Recipe();
		testInventory.enoughIngredients(testRecipe);
		testRecipe.setPrice(100);
		int result = cm.makeCoffee(testRecipe, amtPaid);
		//fail(getName());
	}
	
	public void testMakeCoffee2(){
		Inventory testInventory = new Inventory();
		testInventory.setCoffee(10);
		testInventory.setMilk(10);
		testInventory.setSugar(10);
		testInventory.setChocolate(10);
		Recipe testRecipe2 = new Recipe();
		
		testRecipe2.setAmtCoffee(20);
		testRecipe2.setAmtMilk(20);
		testRecipe2.setAmtSugar(20);
		testRecipe2.setAmtChocolate(20);
		boolean result = testInventory.enoughIngredients(testRecipe2);
		cm.makeCoffee(testRecipe2, 2);
		assertFalse(result);
		
	}
	
	public void testMakeCoffee3(){
		Recipe testRescipe= new Recipe();
		int testAmtPaid=1;
		cm.makeCoffee(testRescipe, testAmtPaid);
	}
	
	
	public void testRecipies(){
		
		Recipe[] testRecipeArray = new Recipe[3];
		//Recipe newTestRecipe= new Recipe();
		//newTestRecipe.setName("testCoffee");
		//int testNum_recipies=3;
		//testRecipeArray= new Recipe[testNum_recipies];
		//Recipe testRecipe = new Recipe();
		//testRecipe.setName("testCoffee");
		testRecipeArray[0]= new Recipe();
		testRecipeArray[0].setName("Coffee");
		Recipe[] testRecipeArray1 = cm.getRecipes();
//		cm.addRecipe(testRecipeArray[0]);
	}
	
	
	public void testAddRecipe(){
		
			assertTrue(cm.addRecipe(r1));
	}
	public void testCMGetRecipeForName(){
		cm.addRecipe(r1);
		Recipe newRecipe = new Recipe();
		newRecipe = r1;
		r1.setName("testCoffee");
		String testName="testCoffee";
		cm.getRecipeForName(testName);
	}

}